package com.ruoyi.travel.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.travel.domain.GuideDetail;
import com.ruoyi.travel.service.IGuideDetailService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 旅游攻略Controller
 * 
 * @author ruoyi
 * @date 2024-12-07
 */
@RestController
@RequestMapping("/travel/guideDetail")
public class GuideDetailController extends BaseController
{
    @Autowired
    private IGuideDetailService guideDetailService;

    /**
     * 查询旅游攻略列表
     */
    @PreAuthorize("@ss.hasPermi('travel:guideDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(GuideDetail guideDetail)
    {
        startPage();
        List<GuideDetail> list = guideDetailService.selectGuideDetailList(guideDetail);
        return getDataTable(list);
    }

    /**
     * 导出旅游攻略列表
     */
    @PreAuthorize("@ss.hasPermi('travel:guideDetail:export')")
    @Log(title = "旅游攻略", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, GuideDetail guideDetail)
    {
        List<GuideDetail> list = guideDetailService.selectGuideDetailList(guideDetail);
        ExcelUtil<GuideDetail> util = new ExcelUtil<GuideDetail>(GuideDetail.class);
        util.exportExcel(response, list, "旅游攻略数据");
    }

    /**
     * 获取旅游攻略详细信息
     */
    @PreAuthorize("@ss.hasPermi('travel:guideDetail:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(guideDetailService.selectGuideDetailById(id));
    }

    /**
     * 新增旅游攻略
     */
    @PreAuthorize("@ss.hasPermi('travel:guideDetail:add')")
    @Log(title = "旅游攻略", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody GuideDetail guideDetail)
    {
        return toAjax(guideDetailService.insertGuideDetail(guideDetail));
    }

    /**
     * 修改旅游攻略
     */
    @PreAuthorize("@ss.hasPermi('travel:guideDetail:edit')")
    @Log(title = "旅游攻略", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody GuideDetail guideDetail)
    {
        return toAjax(guideDetailService.updateGuideDetail(guideDetail));
    }

    /**
     * 删除旅游攻略
     */
    @PreAuthorize("@ss.hasPermi('travel:guideDetail:remove')")
    @Log(title = "旅游攻略", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(guideDetailService.deleteGuideDetailByIds(ids));
    }
}
